This script can be used to create bi-plots and Harker plots of all tephra major elemental data. It includes interactive exploration of the data and some discussion on identifying useful elements for discrimination. Guidance for saving plots as .svg or .pdf files is also provided. All the code used to produce this document is downloadable as an RMarkdown file. To run this you will require r and RStudio. We are happy for you to use, share and improve our code, but would ask that you cite this as a poin tof origin for the plots.
We first load in packages required to generate the plots and manipulate the data. You may need to install these packages in r or update them to work correctly.
library(ggplot2)
library(factoextra)
library(readr)
library(compositions)
library(gganimate)
library(cowplot)
library(tidyverse)
library(gt)
library(plotly)
library(svglite)
library(png)
library(here)
library(ggdensity)
Any data placed within the the data file of the r project can be read using the code outlined below. As this is a Markdown script the ‘here’ package is used to ensure that project links do not break when moving scripts around. As long as you start a new R project and drop this script into it (using the structure outlined on the home page) then it will work. Data files should be in .csv format and contain the group of the tephra as column 1 under the title “id” (see example files for reference). Loaded here are some data for core ODP-980 in the North Atlantic and a terrestrial site from the UK called MT.
chem <- here::here("Data","Borrobol_type.csv") %>% read.csv()
The following script produces a summary table of mean values and number of analyses in your data.
chem_sum <- chem %>% group_by(id) %>% dplyr::summarise(
count=n(),
SiO2.= mean(SiO2),
dev_1 = sd(SiO2),
TiO2. = mean(TiO2),
dev_2 = sd(TiO2),
Al2O3. = mean(Al2O3),
dev_3 = sd(Al2O3),
FeOt = mean(FeO),
dev_4 = sd(FeO),
MnO.= mean(MnO),
dev_5 = sd(MnO),
MgO.= mean(MgO),
dev_6 = sd(MgO),
CaO.= mean(CaO),
dev_7 = sd(CaO),
Na2O. = mean(Na2O),
dev_8 = sd(Na2O),
K2O. = mean(K2O),
dev_9 = sd(K2O),
P2O5. = mean(P2O5),
dev_10 = sd(P2O5),
Total.=mean(Total),
dev_11 = sd(Total))
chem_sum <- chem_sum %>% mutate(across(where(is.numeric), ~ round(., digits = 2)))
chem_sum %>% rename(layer = id, n = count , SiO2 = SiO2., sd1 = dev_1, TiO2 = TiO2. , sd2 = dev_2)
## # A tibble: 12 x 24
## layer n SiO2 sd1 TiO2 sd2 Al2O3. dev_3 FeOt dev_4 MnO. dev_5
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 Borrobol-~ 2 76.4 0.39 0.07 0.01 13.0 0.42 0.95 0.01 0.05 0.01
## 2 Borrobol-~ 12 76.4 0.41 0.12 0.01 12.7 0.34 1.56 0.12 0.04 0.01
## 3 Borrobol-~ 8 76.4 0.59 0.12 0.01 12.6 0.57 1.47 0.15 0.04 0.01
## 4 Borrobol-~ 35 75.9 0.31 0.15 0.01 12.9 0.2 1.58 0.13 0.04 0.01
## 5 Borrobol ~ 124 76.4 0.36 0.13 0.01 12.7 0.21 1.55 0.11 0.04 0.01
## 6 Borrobol ~ 13 76.5 0.25 0.13 0.01 12.8 0.23 1.53 0.1 0.04 0.01
## 7 Borrobol ~ 21 76.5 0.54 0.12 0.02 12.9 0.48 1.36 0.16 0.04 0.01
## 8 CRUM1 597~ 28 76.7 0.27 0.13 0.01 12.6 0.21 1.53 0.11 0.04 0.01
## 9 Fosen Tep~ 10 76.9 0.49 0.12 0.01 12.3 0.43 1.54 0.2 0.05 0
## 10 Hasseldal~ 104 77.8 0.5 0.09 0.02 12.2 0.32 1.14 0.14 0.04 0.02
## 11 Hovsdalur~ 23 77.9 0.53 0.12 0.02 12.3 0.12 1.16 0.12 0.04 0.02
## 12 Penifiler~ 171 76.8 0.49 0.12 0.02 12.8 0.31 1.36 0.2 0.04 0.02
## # ... with 12 more variables: MgO. <dbl>, dev_6 <dbl>, CaO. <dbl>, dev_7 <dbl>,
## # Na2O. <dbl>, dev_8 <dbl>, K2O. <dbl>, dev_9 <dbl>, P2O5. <dbl>,
## # dev_10 <dbl>, Total. <dbl>, dev_11 <dbl>
gt(chem_sum)
| id | count | SiO2. | dev_1 | TiO2. | dev_2 | Al2O3. | dev_3 | FeOt | dev_4 | MnO. | dev_5 | MgO. | dev_6 | CaO. | dev_7 | Na2O. | dev_8 | K2O. | dev_9 | P2O5. | dev_10 | Total. | dev_11 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Borrobol-type Tephra GI-1a | 2 | 76.37 | 0.39 | 0.07 | 0.01 | 13.04 | 0.42 | 0.95 | 0.01 | 0.05 | 0.01 | 0.04 | 0.00 | 0.69 | 0.18 | 4.01 | 0.03 | 4.77 | 0.21 | 0.01 | 0.01 | 100 | 0 |
| Borrobol-type Tephra GI-1e_pt1 | 12 | 76.38 | 0.41 | 0.12 | 0.01 | 12.72 | 0.34 | 1.56 | 0.12 | 0.04 | 0.01 | 0.08 | 0.03 | 0.81 | 0.07 | 4.13 | 0.15 | 3.92 | 0.11 | 0.01 | 0.01 | 100 | 0 |
| Borrobol-type Tephra GI-1e_pt2 | 8 | 76.42 | 0.59 | 0.12 | 0.01 | 12.64 | 0.57 | 1.47 | 0.15 | 0.04 | 0.01 | 0.07 | 0.02 | 0.84 | 0.04 | 4.16 | 0.20 | 3.99 | 0.07 | 0.01 | 0.00 | 100 | 0 |
| Borrobol-type:GS-2.1-RHY Tephra | 35 | 75.87 | 0.31 | 0.15 | 0.01 | 12.91 | 0.20 | 1.58 | 0.13 | 0.04 | 0.01 | 0.11 | 0.02 | 0.96 | 0.05 | 4.27 | 0.15 | 3.94 | 0.10 | 0.02 | 0.01 | 100 | 0 |
| Borrobol Tephra | 124 | 76.43 | 0.36 | 0.13 | 0.01 | 12.74 | 0.21 | 1.55 | 0.11 | 0.04 | 0.01 | 0.08 | 0.02 | 0.78 | 0.05 | 4.26 | 0.21 | 3.94 | 0.10 | 0.01 | 0.01 | 100 | 0 |
| Borrobol Tephra-Sweden | 13 | 76.50 | 0.25 | 0.13 | 0.01 | 12.76 | 0.23 | 1.53 | 0.10 | 0.04 | 0.01 | 0.07 | 0.02 | 0.77 | 0.05 | 4.24 | 0.32 | 3.96 | 0.13 | 0.01 | 0.00 | 100 | 0 |
| Borrobol Tephra - ASHIK | 21 | 76.46 | 0.54 | 0.12 | 0.02 | 12.92 | 0.48 | 1.36 | 0.16 | 0.04 | 0.01 | 0.06 | 0.03 | 0.70 | 0.10 | 4.21 | 0.51 | 3.95 | 0.10 | 0.01 | 0.01 | 100 | 0 |
| CRUM1 597 Tephra | 28 | 76.67 | 0.27 | 0.13 | 0.01 | 12.59 | 0.21 | 1.53 | 0.11 | 0.04 | 0.01 | 0.07 | 0.02 | 0.77 | 0.06 | 4.30 | 0.14 | 3.91 | 0.09 | 0.00 | 0.00 | 100 | 0 |
| Fosen Tephra | 10 | 76.88 | 0.49 | 0.12 | 0.01 | 12.31 | 0.43 | 1.54 | 0.20 | 0.05 | 0.00 | 0.07 | 0.03 | 0.70 | 0.12 | 4.30 | 0.14 | 4.02 | 0.30 | 0.01 | 0.00 | 100 | 0 |
| Hasseldalen Tephra | 104 | 77.75 | 0.50 | 0.09 | 0.02 | 12.15 | 0.32 | 1.14 | 0.14 | 0.04 | 0.02 | 0.03 | 0.02 | 0.51 | 0.09 | 4.03 | 0.27 | 4.22 | 0.24 | 0.01 | 0.02 | 100 | 0 |
| Hovsdalur Tephra | 23 | 77.88 | 0.53 | 0.12 | 0.02 | 12.27 | 0.12 | 1.16 | 0.12 | 0.04 | 0.02 | 0.05 | 0.02 | 0.49 | 0.06 | 3.61 | 0.24 | 4.38 | 0.60 | 0.01 | 0.00 | 100 | 0 |
| Penifiler Tephra | 171 | 76.78 | 0.49 | 0.12 | 0.02 | 12.77 | 0.31 | 1.36 | 0.20 | 0.04 | 0.02 | 0.05 | 0.03 | 0.69 | 0.10 | 4.10 | 0.40 | 4.02 | 0.12 | 0.01 | 0.02 | 100 | 0 |
To calculate for the TAS plot the data require normalisation of the data. The rest of the script uses unnormalised data for plotting, but the code below can be used to normalise other data also by replacing the element to be normalise.
TAS_x <- (100/ chem [["Total"]]) * chem [["SiO2"]]
TAS_y <- (100/ chem [["Total"]]) * (chem [["K2O"]] + chem [["Na2O"]])
chem <- cbind(chem, TAS_x, TAS_y)
It is possible your datasheet contains multiple types of tephra which would benefit from filtering before plotting. I suggest this is carried out by using silica values as a divisor. Rhyolites >69% silica is a case for this. However, it might be worth plotting everything first before then selecting a filter to ensure vital data is not being excluded.
chem <- filter(chem, SiO2 >68)
First we generate a series of plots from all possible pairs of elements.
p1 <- ggplot(chem, aes(x = TAS_x, y = TAS_y, fill = id, shape = id))
p2 <- ggplot(chem, aes(x = SiO2, y = TiO2, fill = id, shape = id))
p3 <- ggplot(chem, aes(x = SiO2, y = Al2O3, fill = id, shape = id))
p4 <- ggplot(chem, aes(x = SiO2, y = FeO, fill = id, shape = id))
p5 <- ggplot(chem, aes(x = SiO2, y = MnO, fill = id, shape = id))
p6 <- ggplot(chem, aes(x = SiO2, y = MgO, fill = id, shape = id))
p7 <- ggplot(chem, aes(x = SiO2, y = CaO, fill = id, shape = id))
p8 <- ggplot(chem, aes(x = SiO2, y = Na2O, fill = id, shape = id))
p9 <- ggplot(chem, aes(x = SiO2, y = K2O, fill = id, shape = id))
p47 <- ggplot(chem, aes(x = SiO2, y = K2O, fill = id, shape = id))
p10 <- ggplot(chem, aes(x = SiO2, y = P2O5, fill = id, shape = id))
p11 <- ggplot(chem, aes(x = TiO2, y = Al2O3, fill = id, shape = id))
p12 <- ggplot(chem, aes(x = TiO2, y = FeO, fill = id, shape = id))
p13 <- ggplot(chem, aes(x = TiO2, y = MnO, fill = id, shape = id))
p14 <- ggplot(chem, aes(x = TiO2, y = MgO, fill = id, shape = id))
p15 <- ggplot(chem, aes(x = TiO2, y = CaO, fill = id, shape = id))
p16 <- ggplot(chem, aes(x = TiO2, y = Na2O, fill = id, shape = id))
p17 <- ggplot(chem, aes(x = TiO2, y = K2O, fill = id, shape = id))
p18 <- ggplot(chem, aes(x = TiO2, y = P2O5, fill = id, shape = id))
p19 <- ggplot(chem, aes(x = Al2O3, y = FeO, fill = id, shape = id))
p20 <- ggplot(chem, aes(x = Al2O3, y = MnO, fill = id, shape = id))
p21 <- ggplot(chem, aes(x = Al2O3, y = MgO, fill = id, shape = id))
p22 <- ggplot(chem, aes(x = Al2O3, y = CaO, fill = id, shape = id))
p23 <- ggplot(chem, aes(x = Al2O3, y = Na2O, fill = id, shape = id))
p24 <- ggplot(chem, aes(x = Al2O3, y = K2O, fill = id, shape = id))
p25 <- ggplot(chem, aes(x = Al2O3, y = P2O5, fill = id, shape = id))
p26 <- ggplot(chem, aes(x = FeO, y = MnO, fill = id, shape = id))
p27 <- ggplot(chem, aes(x = FeO, y = MgO, fill = id, shape = id))
p28 <- ggplot(chem, aes(x = FeO, y = CaO, fill = id, shape = id))
p29 <- ggplot(chem, aes(x = FeO, y = Na2O, fill = id, shape = id))
p30 <- ggplot(chem, aes(x = FeO, y = K2O, fill = id, shape = id))
p31 <- ggplot(chem, aes(x = FeO, y = P2O5, fill = id, shape = id))
p32 <- ggplot(chem, aes(x = MnO, y = MgO, fill = id, shape = id))
p33 <- ggplot(chem, aes(x = MnO, y = CaO, fill = id, shape = id))
p34 <- ggplot(chem, aes(x = MnO, y = Na2O, fill = id, shape = id))
p35 <- ggplot(chem, aes(x = MnO, y = K2O, fill = id, shape = id))
p36 <- ggplot(chem, aes(x = MnO, y = P2O5, fill = id, shape = id))
p37 <- ggplot(chem, aes(x = MgO, y = CaO, fill = id, shape = id))
p38 <- ggplot(chem, aes(x = MgO, y = Na2O, fill = id, shape = id))
p39 <- ggplot(chem, aes(x = MgO, y = K2O, fill = id, shape = id))
p40 <- ggplot(chem, aes(x = MgO, y = P2O5, fill = id, shape = id))
p41 <- ggplot(chem, aes(x = CaO, y = Na2O, fill = id, shape = id))
p42 <- ggplot(chem, aes(x = CaO, y = K2O, fill = id, shape = id))
p43 <- ggplot(chem, aes(x = CaO, y = P2O5, fill = id, shape = id))
p44 <- ggplot(chem, aes(x = Na2O, y = K2O, fill = id, shape = id))
p45 <- ggplot(chem, aes(x = Na2O, y = P2O5, fill = id, shape = id))
p46 <- ggplot(chem, aes(x = K2O, y = P2O5, fill = id, shape = id))
To ensure consistency and to provide a shortcut of coding it everytime we set up[ a custom tephra plotting theme. This means all of our plots will have the same sized fonts etc…
Tephra.theme <-theme_bw()+theme(axis.title.x=element_text(size=16),
axis.title.y=element_text(size=16),
axis.text.x=element_text(size=16),
axis.text.y=element_text(size=16))+
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank())
The hex numbers below specify a custom colour palette for plotting. These can be altered but were slected in order to help those with colour vision deficiencies, and this should be considered when making changes. At present 35 layers can be plotted using this pallete. If you have more than 35 groups of data you will either have to specify additional colours or consider splitting your dataset. The latter might be more appropriate for improving the final clarity in the plots.
chempalette <- c("#209A24","#A769EE","#B4C428","#e30303","#000000","#EF139D","#3A700F","#5288FF","#E64701","#7F9AF5","#F36D20","#0B3075","#C18522","#9634A6","#1D7D46","#80ddb8","#7CBC92","#B10E89","#384B27","#F896FD","#C6A766","#20628E","#9C0323","#C3AFE0","#572D24","#FF79A2","#3E6D6F","#E18C63","#6F2B40","#DF9FB4", "#291700", "#7e005b", "#00597a" , "#7b003a", "#470600")
The palette is known as “chempalette”.
We first generate the simple bi-plots of each element. This initial explorative approach facilitates data checking for unusual analyses and permits the identification of elements with significant variability.
p21 <- p21 + geom_point(aes(fill = id), size=4, alpha=0.8)+xlab("Al2O3 (wt%)")+ylab("MgO (wt%)")+scale_shape_manual(values=c(21:25, 21:25, 21:25, 21:25, 21:25, 21:25, 21:25, 21:25, 21:25, 21:25))+
scale_fill_manual(values = chempalette) +
Tephra.theme
p21
# {-}
We propose exporting your plots in .svg format. This is a vector file format that preserves your data without size and scaling issues. It is also readable and editable by software like Adobe Illustrator, Affinity Designer, or free alternatives like Inkscape. .Using the file structure presented here the all plots can be named appropriately and will be saved in the Output -> Plots folder. The width and height and dpi outputs can be altered but override the preview functions in Rstudio and we recommend that you view the svg file directly in you preferred image editor to understand how it might look.
ggsave( filename = file.path("Script", "Output","Plots","fig1.svg"), plot = p1, width = 12, height = 6, dpi = 300)
Multivariate analysis via ordination is often a helpful way of exploring your data. It permits the identification of useful elements for discrimination and facilitates dimension reduction. Unfortunately, percentage data can have problematic covariation and should be ‘freed’ from their compositional sum where possible. This can be achieved via undertaking a centred log-ratio transform.
chem_multi <- chem[ -c(1,6,11,12)] ## check columns to drop. Currently dropping id, MnO, P2O5, and Total to perform the clr transform.
chem_multi[is.na(chem_multi)] <- 0.005 # replace NAs with half the detection limit
chem_multi_clr <- clr(chem_multi)
cmclr <- as.data.frame(chem_multi_clr)
head(cmclr)
## Sites Country age SiO2 Al2O3 FeO MnO MgO
## 1 1.642765 0.3618315 0.3618315 3.093085 1.280336 -0.8536068 -4.394162 -3.397470
## 2 1.667643 0.3867093 0.3867093 3.117234 1.315663 -0.7952411 -4.167768 -3.906574
## 3 1.670452 0.3895177 0.3895177 3.118529 1.321894 -0.7552432 -4.170679 -3.650339
## 4 1.652841 0.3719074 0.3719074 3.100923 1.300696 -0.8593681 -4.363371 -3.507648
## 5 1.668021 0.3870871 0.3870871 3.116741 1.313589 -0.7739540 -4.443730 -3.871661
## 6 1.662949 0.3820153 0.3820153 3.110569 1.319112 -0.8551696 -4.348718 -3.800505
## K2O P2O5 Cl F Total TAS_x TAS_y
## 1 0.1503695 -5.545292 0 0 3.357564 3.093085 0.8496628
## 2 0.1328745 -5.505815 0 0 3.382442 3.117234 0.8688885
## 3 0.1163958 -5.795532 0 0 3.385250 3.118529 0.8617065
## 4 0.1676347 -5.580336 0 0 3.367640 3.100923 0.8762521
## 5 0.1645933 -5.314697 0 0 3.382819 3.116741 0.8673628
## 6 0.1412168 -5.362589 0 0 3.377748 3.110569 0.8807886
We can summarise the importance of the resulting principal components by summarizing how much of the total variance is captured by each principal component.
| Information | PC1 | PC2 | PC3 | PC4 | PC5 | PC6 | PC7 | PC8 | PC9 | PC10 | PC11 | PC12 | PC13 | PC14 | PC15 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Standard deviation | 2.774224 | 2.161704 | 1.413388 | 0.7742391 | 0.6098498 | 0.5320467 | 0.2919113 | 0.2413936 | 0.1237158 | 0.04010732 | 0.0306669 | 0.02399163 | 0.001124607 | 8.722397e-16 | 7.458682e-17 |
| Proportion of Variance | 0.487620 | 0.296070 | 0.126570 | 0.0379800 | 0.0235600 | 0.0179400 | 0.0054000 | 0.0036900 | 0.0009700 | 0.00010000 | 0.0000600 | 0.00004000 | 0.000000000 | 0.000000e+00 | 0.000000e+00 |
| Cumulative Proportion | 0.487620 | 0.783690 | 0.910260 | 0.9482400 | 0.9718100 | 0.9897400 | 0.9951400 | 0.9988300 | 0.9998000 | 0.99990000 | 0.9999600 | 1.00000000 | 1.000000000 | 1.000000e+00 | 1.000000e+00 |
If this has captured a significant amount of variation it would be worth plotting the output in order to identify the important variables in determining the changes observed.
This is a visual representation of the summary table showing the percentage of the total variance explained by each dimension.
## Scale for 'shape' is already present. Adding another scale for 'shape', which
## will replace the existing scale.
The function ggplotly within the plotly package is extremely useful for interactively examining data. ggplotly plots allow you to zoom into areas of interest and turn layers on and off as well as saving low resolution .png files of zoomed sections of your plots.We refer to these as iPlots in order to distinguish them from static plots presented above.
l <- list(p1, p2, p3, p4, p5, p6, p7, p8, p9, p47, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27, p28, p29, p30, p31, p32, p33, p34, p35, p36, p37, p38, p39, p40, p41, p42, p43, p44, p45, p46)
pdf("allplotsout.pdf", width = 12, height = 6)
invisible(lapply(l, print))
dev.off()
## png
## 2
It is frequently useful to plot all of the collected elemental data against SiO[2]. This permits an assessme tof groupings within the data and which elements might be useful discriminators. Additionally, wt% K2O vs SiO2 can further classify the tephra to low, mid and high Potassium values. The dividing lines included here are from xxxxxxxx.
g1 <- plot_grid(p1 + theme(legend.position = "none"),
p2 + theme(legend.position = "none"),
p3 + theme(legend.position="none"),
p4 + theme(legend.position="none"),
p5 + theme(legend.position="none"),
p6 + theme(legend.position="none"),
p7 + theme(legend.position="none"),
p8 + theme(legend.position="none"),
p47 + theme(legend.position="none"),
p10 + theme(legend.position="none"),
labels = c("A", "B", "C", "D", "E", "F", "G", "H", "I", "J"), align = "b")
legend <- get_legend(p1)
legplot <- plot_grid(legend)
px <- plot_grid( g1, rel_widths = c(4, 1))
l2 <- list(px,legplot)
pdf("Script/Output/Plots/Harkerplot.pdf", width = 30, height = 20)
invisible(lapply(l2, print))
dev.off()
## png
## 2
ggsave( filename = file.path("Script","Output","Plots","Harker.svg"), plot = px, width = 30, height = 20, dpi = 300)
print(g1)
p100 <- ggplot(chem, aes(x = TAS_x, y = TAS_y, fill = id, shape = id))
p100 <- p100 + geom_point(aes(fill = id), size=4, alpha=0.8)+xlab("SiO2 (wt%)")+ylab("Na2O+K2O (wt%)")+
scale_shape_manual(values=c(21:25, 21:25, 21:25, 21:25, 21:25, 21:25, 21:25, 21:25, 21:25, 21:25))+
scale_fill_manual(values = chempalette) +geom_segment(x=77,y=0,xend=69,yend=8)+
geom_segment(x=69, y=8,xend=69,yend=13)+geom_segment(x=41, y=7,xend=52.5,yend=14)+
geom_segment(x=52.5,y=14,xend=57.6,yend=11.7)+geom_segment(x=45,y=0,xend=45,yend=5)+
geom_segment(x=45,y=5,xend=63,yend=14.56)+geom_segment(x=52,y=0,xend=52,yend=5)+
geom_segment(x=52,y=5,xend=63,yend=7)+geom_segment(x=57,y=0,xend=57,yend=5.9)+
geom_segment(x=63,y=0,xend=63,yend=7)+geom_segment(x=45,y=5,xend=52,yend=5)+
geom_segment(x=52,y=5,xend=49.4,yend=7.3)+geom_segment(x=57,y=5.9,xend=53,yend=9.3)+
geom_segment(x=63,y=7,xend=57.6,yend=11.7)+geom_segment(x=49.4,y=7.3,xend=45,yend=9.4)+
geom_segment(x=53,y=9.3,xend=48.4,yend=11.5)+geom_segment(x=41,y=0,xend=41,yend=7)+
geom_segment(x=52.5,y=14,xend=49,yend=15.5)+geom_segment(x=41,y=3,xend=45,yend=3)+
geom_segment(x=63,y=7,xend=69,yend=8)+
scale_x_continuous(limits=c(74, 79), expand = c(0, 0)) + ## set x axis of insert
scale_y_continuous(limits=c(6, 10.5), expand = c(0, 0)) + ## set y axis of insert
theme_bw()+theme(axis.title.x=element_text(size=9), axis.title.y=element_text(size=9),
axis.text.x=element_text(size=9), axis.text.y=element_text(size=9))+ ## change the text size as neccessary
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), legend.position = "none")
fig_in <- p1 + annotation_custom(ggplotGrob(p100), xmin = 40, xmax = 56, ymin = 7, ymax = 16) + ## place the insert
annotate("rect", xmin = 74, xmax = 79, ymin = 6, ymax = 10.5,
alpha = .2) ## use this to highlight the area of the insert plot
ggsave( filename = file.path("Script", "Output","Plots","insert_plot.svg"), plot = fig_in, width = 10, height = 6, dpi = 300)
print(fig_in)
## Creating a HDR plot to simplify your data. Simplifying the data we
create to make more visually compelling figures can be acheived using
highest density regions. The following code permits this as an addition
to the previosuly created plots. It can be added easily to any of the
previously created plots by changing the p code. Visibility of the
density regions can be applied to just reference data or entire
datasets. Opacity is varied using the alpha command and the probability
range can be altered in the ‘probs’ argument. You may need to vary the x
and y axes in order to fit the full range in to the plot.
p28den <- p28 +
geom_hdr(stat= "hdr", method = "kde", na.rm = TRUE, inherit.aes = TRUE, alpha = 0.3, xlim = c(0,100), ylim = c(0,30), smooth = TRUE, n = 1000, probs = c(0.75))
print(p28den)
The plots are nice but messy and still have lots of overplotting. If you have particularly messy data I’d suggest creating plot ‘facets’ using the following code.
p28den_facet <- p28 +
geom_hdr(method = "kde", alpha = 0.5, xlim = c(0,100), ylim = c(0,30), show.legend = FALSE, smooth = TRUE, n = 1000, probs = c(0.95)) +
facet_wrap(~ id)
print(p28den_facet)
chem2 <- dplyr::select(chem, -Total)
chem2 <- rename(chem2, id2=id)
f19 <- ggplot(chem, aes(x = Al2O3, y = CaO, fill = id, shape = id))
f19 <- f19 +
geom_point(data = chem2, inherit.aes = FALSE, aes(x=Al2O3, y = CaO, shape = id2), colour = "grey70") +
geom_point(aes(fill = id), size=4, alpha=0.8)+xlab("Al2O3 (wt%)")+ylab("CaO (wt%)")+scale_shape_manual(values=c(21:25, 21:25, 21:25, 21:25, 21:25, 21:25, 21:25, 21:25, 21:25, 21:25))+
scale_fill_manual(values = chempalette) +
Tephra.theme +
facet_wrap(~ id)
ggsave( filename = file.path("Script", "Output","Plots","faceted plot.pdf"), plot = f19, width = 25, height = 16, units = "cm", dpi = 300)
print(f19)
unknowns <- here::here("Data","Ardtoe_16.5_B_type.csv") %>% read.csv()
gt(unknowns)
| id2 | SiO2 | TiO2 | Al2O3 | FeO | MnO | MgO | CaO | Na2O | K2O | Cl | P2O5 | Total |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 380 | 76.00313 | 0.13204995 | 12.90136 | 1.5669031 | 0.05215766 | 0.073890020 | 0.8094786 | 4.229427 | 4.206867 | 0 | 0.024940469 | 100 |
| 387 | 76.59048 | 0.12320307 | 12.46894 | 1.5890809 | 0.05106648 | 0.039752971 | 0.7755462 | 4.462193 | 3.900151 | 0 | 0.005189683 | 100 |
| 387 | 75.92839 | 0.11049529 | 13.42150 | 1.3561821 | 0.05105359 | 0.052917614 | 0.6484738 | 4.296372 | 4.118461 | 0 | 0.016258445 | 100 |
| 410 | 77.24444 | 0.11317187 | 11.92802 | 1.3273489 | 0.04997470 | 0.024466780 | 0.6460271 | 4.554777 | 4.095010 | 0 | 0.016658233 | 100 |
| 410 | 76.65740 | 0.14601109 | 12.19382 | 1.4629552 | 0.03929447 | 0.111457235 | 0.8955557 | 4.487471 | 3.965581 | 0 | 0.040453288 | 100 |
| 420 | 76.25817 | 0.14687726 | 12.63333 | 1.5402689 | 0.03212612 | 0.093858662 | 0.8514471 | 4.611148 | 3.811250 | 0 | 0.021627387 | 100 |
| 420 | 77.32078 | 0.10893876 | 12.62702 | 1.1756351 | 0.02867915 | 0.024266975 | 0.5681203 | 4.075696 | 4.062144 | 0 | 0.008824354 | 100 |
| 420 | 76.94974 | 0.11294698 | 12.32582 | 1.3819579 | 0.05475269 | 0.055065562 | 0.6674614 | 4.356958 | 4.079858 | 0 | 0.015330753 | 100 |
| 420 | 77.23369 | 0.10020921 | 11.99594 | 1.4343671 | 0.03381673 | 0.025853769 | 0.6393120 | 4.414686 | 4.112197 | 0 | 0.010031262 | 100 |
| 420 | 76.05568 | 0.10702770 | 12.62792 | 1.5104649 | 0.04185324 | 0.086829867 | 0.7079653 | 4.610416 | 4.240192 | 0 | 0.011764718 | 100 |
| 420 | 75.52786 | 0.16410136 | 13.05794 | 1.6359643 | 0.03976302 | 0.097514075 | 0.9487373 | 4.601044 | 3.897197 | 0 | 0.029980055 | 100 |
| 420 | 76.54834 | 0.12191103 | 12.38466 | 1.3845089 | 0.04515610 | 0.076546362 | 0.6711885 | 4.759640 | 3.979889 | 0 | 0.028157381 | 100 |
| 420 | 76.39237 | 0.15275863 | 12.77143 | 1.5077351 | 0.06188900 | 0.097238986 | 0.8168712 | 4.433079 | 3.745612 | 0 | 0.021018907 | 100 |
| 442 | 77.21185 | 0.10646580 | 12.22102 | 1.2313233 | 0.03903392 | 0.071260827 | 0.7180326 | 4.497622 | 3.883715 | 0 | 0.019782857 | 100 |
| 442 | 76.69401 | 0.10237887 | 12.23788 | 1.3744285 | 0.03858815 | 0.053542372 | 0.7210442 | 4.747284 | 4.009403 | 0 | 0.021542439 | 100 |
| 442 | 76.47075 | 0.11102017 | 12.70541 | 1.1456694 | 0.04764003 | 0.067577494 | 0.6471280 | 4.583412 | 4.204076 | 0 | 0.017314109 | 100 |
| 442 | 76.74392 | 0.11867632 | 12.73449 | 1.1364819 | 0.03539469 | 0.014157877 | 0.5949431 | 4.177302 | 4.424961 | 0 | 0.019779387 | 100 |
| 454 | 75.76463 | 0.13949886 | 12.82045 | 1.5436909 | 0.05801250 | 0.074144316 | 0.7587125 | 4.976045 | 3.837304 | 0 | 0.027506817 | 100 |
| 454 | 75.46961 | 0.12623091 | 13.23725 | 1.6791525 | 0.04617695 | 0.102673364 | 0.8101293 | 4.674400 | 3.828935 | 0 | 0.025538045 | 100 |
| 454 | 75.56446 | 0.14010431 | 12.78176 | 1.7300202 | 0.05034506 | 0.095329786 | 0.8687938 | 4.773006 | 3.975683 | 0 | 0.020390274 | 100 |
| 454 | 76.31437 | 0.13383242 | 12.64378 | 1.5893251 | 0.05717821 | 0.089464629 | 0.8199709 | 4.441466 | 3.884265 | 0 | 0.026245735 | 100 |
| 454 | 75.97227 | 0.14575976 | 12.91750 | 1.5434188 | 0.03583741 | 0.091270132 | 0.8381972 | 4.493089 | 3.951337 | 0 | 0.011526653 | 100 |
| 454 | 75.98706 | 0.14838109 | 13.24833 | 1.4673473 | 0.03240626 | 0.109201816 | 0.8817421 | 4.331603 | 3.768921 | 0 | 0.025008049 | 100 |
| 454 | 76.04285 | 0.15673637 | 12.86868 | 1.6107275 | 0.04817031 | 0.079308605 | 0.7418855 | 4.458836 | 3.981417 | 0 | 0.011494001 | 100 |
| 475 | 77.17689 | 0.11083083 | 12.21404 | 1.3087988 | 0.02836931 | 0.064783636 | 0.7981513 | 4.204691 | 4.080099 | 0 | 0.013443663 | 100 |
| 475 | 76.62986 | 0.11424276 | 12.72582 | 1.2411494 | 0.03463182 | 0.020905791 | 0.6802829 | 4.507521 | 4.027532 | 0 | 0.018160586 | 100 |
| 475 | 76.14597 | 0.16576605 | 12.68678 | 1.4035489 | 0.04758683 | 0.112716714 | 0.9232686 | 4.548167 | 3.944770 | 0 | 0.021324784 | 100 |
| 480 | 75.72011 | 0.13144165 | 13.14479 | 1.4961183 | 0.04974306 | 0.113033613 | 0.8535951 | 4.578947 | 3.895368 | 0 | 0.016960213 | 100 |
| 480 | 75.52408 | 0.10334690 | 13.10485 | 1.4388347 | 0.02739943 | 0.048548039 | 0.6299785 | 5.011074 | 4.104393 | 0 | 0.007605165 | 100 |
| 480 | 76.60738 | 0.11195173 | 12.47452 | 1.5198642 | 0.05286032 | 0.066568700 | 0.7041120 | 4.360925 | 4.085303 | 0 | 0.016616212 | 100 |
| 505-510 | 76.65605 | 0.09946791 | 12.89805 | 1.1464222 | 0.02530779 | 0.025722672 | 0.5703588 | 4.287181 | 4.276187 | 0 | 0.015350627 | 100 |
| 505-510 | 76.71721 | 0.09672477 | 12.37239 | 1.2699973 | 0.03887854 | 0.039612095 | 0.5796151 | 4.449968 | 4.429743 | 0 | 0.005868459 | 100 |
| 505-510 | 76.05787 | 0.14955098 | 12.52087 | 1.7823156 | 0.04245861 | 0.093955429 | 0.8774428 | 4.393625 | 4.065622 | 0 | 0.016289812 | 100 |
| 505-510 | 76.24703 | 0.14635568 | 12.82195 | 1.6703978 | 0.04826290 | 0.117941159 | 0.8152461 | 4.284743 | 3.835020 | 0 | 0.013058144 | 100 |
| 505-510 | 75.73803 | 0.14102717 | 12.70740 | 1.7781055 | 0.03686645 | 0.120984282 | 0.8963222 | 4.742584 | 3.830373 | 0 | 0.008307934 | 100 |
| 505-510 | 76.85715 | 0.11324408 | 12.43627 | 1.2549926 | 0.02068385 | 0.003516254 | 0.5168894 | 4.387768 | 4.390457 | 0 | 0.019029141 | 100 |
| 505-510 | 77.57019 | 0.10721989 | 11.96031 | 1.0596218 | 0.02662156 | 0.026516747 | 0.5913339 | 4.564025 | 4.078863 | 0 | 0.015406964 | 100 |
| 505-510 | 76.75269 | 0.10856079 | 13.10689 | 0.9835177 | 0.03759059 | 0.008319228 | 0.5732051 | 4.347156 | 4.061119 | 0 | 0.020952131 | 100 |
| 505-510 | 76.90239 | 0.12989825 | 12.50208 | 1.3284093 | 0.03730896 | 0.050445921 | 0.7178034 | 3.868151 | 4.447649 | 0 | 0.015869446 | 100 |
| 505-510 | 77.16865 | 0.11003945 | 12.48262 | 1.3499987 | 0.04051881 | 0.045858496 | 0.7008602 | 3.895355 | 4.192597 | 0 | 0.013610969 | 100 |
| 505-510 | 76.27339 | 0.10607059 | 12.78489 | 1.3079264 | 0.04881953 | 0.019569451 | 0.6909682 | 4.674601 | 4.078669 | 0 | 0.014885274 | 100 |
| 505-510 | 77.51055 | 0.09643494 | 12.04243 | 1.3480998 | 0.03696149 | 0.035600305 | 0.6335807 | 4.122411 | 4.162199 | 0 | 0.011727159 | 100 |
| 505-510 | 76.83687 | 0.09935218 | 12.23137 | 1.3357812 | 0.04441136 | 0.074435944 | 0.6581430 | 4.373894 | 4.322289 | 0 | 0.023352453 | 100 |
| 505-510 | 76.88847 | 0.10963497 | 12.17229 | 1.3376924 | 0.03654499 | 0.042271412 | 0.6928972 | 4.684943 | 4.021927 | 0 | 0.013535181 | 100 |
| 505-510 | 76.89560 | 0.09150607 | 12.56363 | 1.1051038 | 0.03174278 | 0.004756247 | 0.6305130 | 4.479868 | 4.181465 | 0 | 0.015716296 | 100 |
| 505-510 | 77.18127 | 0.11148237 | 12.42395 | 0.9811715 | 0.02153637 | 0.023647775 | 0.5991122 | 4.429524 | 4.223134 | 0 | 0.004961810 | 100 |
| 520-524 | 76.46034 | 0.11591999 | 12.34764 | 1.4231522 | 0.04443073 | 0.076753566 | 0.6535108 | 4.732294 | 4.123320 | 0 | 0.022531225 | 100 |
| 520-524 | 77.19453 | 0.11599690 | 12.73675 | 1.2753384 | 0.04936929 | 0.063071355 | 0.6914838 | 3.803527 | 4.056754 | 0 | 0.012969897 | 100 |
| 520-524 | 77.29433 | 0.10890360 | 11.97877 | 1.4754344 | 0.02764476 | 0.029634346 | 0.5058782 | 4.020428 | 4.541804 | 0 | 0.017173260 | 100 |
| 520-524 | 77.35520 | 0.10626971 | 11.70494 | 1.2323338 | 0.04144830 | 0.027112799 | 0.5122345 | 4.537394 | 4.475274 | 0 | 0.007894915 | 100 |
| 520-524 | 77.95664 | 0.11758516 | 11.93040 | 1.2341688 | 0.02620047 | 0.037821642 | 0.5859185 | 4.178024 | 3.918977 | 0 | 0.014367998 | 100 |
| 520-524 | 76.54875 | 0.10491271 | 12.84308 | 1.3202392 | 0.04131332 | 0.030380535 | 0.6189640 | 4.446491 | 4.033673 | 0 | 0.012404509 | 100 |
| 520-524 | 75.54970 | 0.14337933 | 12.87527 | 1.7624238 | 0.05149390 | 0.102670599 | 0.9275247 | 4.751079 | 3.822709 | 0 | 0.013745806 | 100 |
| 520-524 | 75.92387 | 0.14512247 | 12.74070 | 1.7208580 | 0.04616577 | 0.125352159 | 0.9112219 | 4.484389 | 3.886022 | 0 | 0.016299987 | 100 |
| 520-524 | 75.96993 | 0.15329138 | 12.74084 | 1.6926837 | 0.03009401 | 0.106896440 | 0.9011485 | 4.511803 | 3.881396 | 0 | 0.011703227 | 100 |
| 520-524 | 77.27263 | 0.11252922 | 12.13558 | 1.2587257 | 0.04014444 | 0.029016316 | 0.6558311 | 4.393632 | 4.091925 | 0 | 0.009984109 | 100 |
| 575-579 | 76.04575 | 0.15342392 | 12.63895 | 1.5826292 | 0.04766769 | 0.094716315 | 0.8835031 | 4.670918 | 3.867686 | 0 | 0.014754284 | 100 |
| 575-579 | 75.96736 | 0.14624645 | 12.64964 | 1.7403431 | 0.04519965 | 0.097915179 | 0.8515907 | 4.646900 | 3.823598 | 0 | 0.031316155 | 100 |
| 605-609 | 76.23718 | 0.14228793 | 13.05039 | 1.5928460 | 0.02999413 | 0.085562195 | 0.8694087 | 4.190548 | 3.789048 | 0 | 0.012629106 | 100 |
| 605-609 | 76.49533 | 0.13253017 | 12.85034 | 1.4540181 | 0.04650739 | 0.083903993 | 0.8073641 | 4.090743 | 4.002178 | 0 | 0.037078785 | 100 |
| 605-609 | 76.45414 | 0.06636754 | 12.85458 | 1.0322203 | 0.05258918 | 0.075412878 | 0.8326970 | 4.011607 | 4.594296 | 0 | 0.026189409 | 100 |
| 605-609 | 76.51119 | 0.13518393 | 12.34711 | 1.6006652 | 0.04506131 | 0.112497177 | 0.8646985 | 4.492810 | 3.870798 | 0 | 0.019980997 | 100 |
| 605-609 | 76.83272 | 0.13504035 | 12.65311 | 1.5101873 | 0.04592211 | 0.109353327 | 0.9304993 | 3.969117 | 3.795598 | 0 | 0.018452719 | 100 |
| 605-609 | 76.16139 | 0.12978653 | 12.58511 | 1.5135492 | 0.04984555 | 0.100736084 | 0.8987874 | 4.658730 | 3.878862 | 0 | 0.023094061 | 100 |
| 605-609 | 76.23662 | 0.13762903 | 12.75444 | 1.4864571 | 0.03350599 | 0.104653197 | 0.8986179 | 4.328104 | 3.993787 | 0 | 0.026083776 | 100 |
| 655-659 | 76.47049 | 0.12827809 | 12.42383 | 1.6668869 | 0.03693327 | 0.087807547 | 0.7680039 | 4.594291 | 3.809017 | 0 | 0.014565233 | 100 |
| 655-659 | 75.65204 | 0.13396388 | 12.84060 | 1.7914653 | 0.03577266 | 0.092211631 | 0.8448012 | 4.766471 | 3.837011 | 0 | 0.005769784 | 100 |
| 655-659 | 75.27886 | 0.15208143 | 13.58467 | 1.3514673 | 0.03711573 | 0.110416699 | 0.8980145 | 4.567302 | 3.987304 | 0 | 0.032773496 | 100 |
| 655-659 | 76.59546 | 0.12812480 | 12.34196 | 1.6668693 | 0.04998218 | 0.074401747 | 0.8927170 | 4.189670 | 4.041179 | 0 | 0.019639567 | 100 |
| 655-659 | 75.96815 | 0.14878880 | 13.20294 | 1.4516593 | 0.04544289 | 0.073085561 | 0.8291756 | 4.398222 | 3.862226 | 0 | 0.020313179 | 100 |
| 655-659 | 76.17420 | 0.13646579 | 13.12513 | 1.6005517 | 0.03745506 | 0.071154179 | 0.7814440 | 4.169614 | 3.877798 | 0 | 0.026395905 | 100 |
| 655-659 | 76.51764 | 0.13979448 | 12.83405 | 1.5541126 | 0.04818713 | 0.099897615 | 0.8837416 | 4.085129 | 3.817975 | 0 | 0.019585736 | 100 |
| 655-659 | 76.50526 | 0.14789827 | 12.54891 | 1.5670923 | 0.03881018 | 0.119682218 | 0.8965153 | 4.335098 | 3.820600 | 0 | 0.019929554 | 100 |
| 655-659 | 76.06042 | 0.15925514 | 12.67322 | 1.4786484 | 0.05235356 | 0.103766635 | 0.9430955 | 4.498749 | 4.009802 | 0 | 0.020795126 | 100 |
| 795-799 | 75.33530 | 0.13666351 | 13.58413 | 1.5086099 | 0.03983466 | 0.087942663 | 0.8680891 | 4.492328 | 3.939545 | 0 | 0.007354090 | 100 |
| 795-799 | 75.98120 | 0.13920379 | 12.90177 | 1.5876109 | 0.02271439 | 0.080750700 | 0.8788802 | 4.534543 | 3.854465 | 0 | 0.018859196 | 100 |
| 795-799 | 76.02033 | 0.14636837 | 12.72681 | 1.6261987 | 0.04571390 | 0.090064775 | 0.8310284 | 4.535322 | 3.953833 | 0 | 0.024429677 | 100 |
| 795-799 | 76.09458 | 0.15805704 | 12.89237 | 1.7420794 | 0.03933120 | 0.124583675 | 0.9393463 | 4.105508 | 3.875692 | 0 | 0.028452359 | 100 |
| 795-799 | 76.11842 | 0.13950288 | 12.91580 | 1.5388064 | 0.05046292 | 0.107181583 | 0.8208566 | 4.333660 | 3.969263 | 0 | 0.006151472 | 100 |
| 795-799 | 76.56116 | 0.13616181 | 12.37317 | 1.6105731 | 0.03365097 | 0.106769143 | 0.8507257 | 4.305871 | 4.007686 | 0 | 0.014332823 | 100 |
| 795-799 | 77.44136 | 0.13002308 | 12.22340 | 1.5432906 | 0.04673831 | 0.071960517 | 0.8779389 | 3.626028 | 4.011361 | 0 | 0.028001804 | 100 |
| 855-859 | 76.52489 | 0.14146244 | 12.69460 | 1.5045983 | 0.04330911 | 0.102033326 | 0.8832751 | 4.261071 | 3.824834 | 0 | 0.020029152 | 100 |
| 855-859 | 76.32537 | 0.14330571 | 13.02532 | 1.4287049 | 0.03301339 | 0.107320056 | 0.8976245 | 4.112343 | 3.908849 | 0 | 0.018152057 | 100 |
| 855-859 | 76.57861 | 0.14483409 | 12.49259 | 1.5230940 | 0.03135476 | 0.100916660 | 0.9157252 | 4.354056 | 3.829434 | 0 | 0.029278290 | 100 |
unknown_sum <- unknowns %>% group_by(id2) %>% dplyr::summarise(
count=n(),
SiO2.= mean(SiO2),
dev_1 = sd(SiO2),
TiO2. = mean(TiO2),
dev_2 = sd(TiO2),
Al2O3. = mean(Al2O3),
dev_3 = sd(Al2O3),
FeOt = mean(FeO),
dev_4 = sd(FeO),
MnO.= mean(MnO),
dev_5 = sd(MnO),
MgO.= mean(MgO),
dev_6 = sd(MgO),
CaO.= mean(CaO),
dev_7 = sd(CaO),
Na2O. = mean(Na2O),
dev_8 = sd(Na2O),
K2O. = mean(K2O),
dev_9 = sd(K2O),
P2O5. = mean(P2O5),
dev_10 = sd(P2O5),
Total.=mean(Total),
dev_11 = sd(Total))
unknown_sum <- unknown_sum %>% mutate(across(where(is.numeric), ~ round(., digits = 2)))
unknown_sum %>% rename(layer = id2, n = count , SiO2 = SiO2., sd1 = dev_1, TiO2 = TiO2. , sd2 = dev_2)
## # A tibble: 15 x 24
## layer n SiO2 sd1 TiO2 sd2 Al2O3. dev_3 FeOt dev_4 MnO. dev_5
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 380 1 76 NA 0.13 NA 12.9 NA 1.57 NA 0.05 NA
## 2 387 2 76.3 0.47 0.12 0.01 13.0 0.67 1.47 0.16 0.05 0
## 3 410 2 77.0 0.42 0.13 0.02 12.1 0.19 1.4 0.1 0.04 0.01
## 4 420 8 76.5 0.61 0.13 0.02 12.6 0.32 1.45 0.14 0.04 0.01
## 5 442 4 76.8 0.31 0.11 0.01 12.5 0.28 1.22 0.11 0.04 0.01
## 6 454 7 75.9 0.29 0.14 0.01 12.9 0.23 1.59 0.09 0.05 0.01
## 7 475 3 76.6 0.52 0.13 0.03 12.5 0.28 1.32 0.08 0.04 0.01
## 8 480 3 76.0 0.58 0.12 0.01 12.9 0.38 1.48 0.04 0.04 0.01
## 9 505-510 16 76.8 0.5 0.11 0.02 12.5 0.31 1.31 0.25 0.04 0.01
## 10 520-524 10 76.8 0.78 0.12 0.02 12.4 0.44 1.44 0.21 0.04 0.01
## 11 575-579 2 76.0 0.06 0.15 0.01 12.6 0.01 1.66 0.11 0.05 0
## 12 605-609 7 76.4 0.23 0.13 0.03 12.7 0.23 1.46 0.19 0.04 0.01
## 13 655-659 9 76.1 0.45 0.14 0.01 12.8 0.4 1.57 0.13 0.04 0.01
## 14 795-799 7 76.2 0.65 0.14 0.01 12.8 0.44 1.59 0.08 0.04 0.01
## 15 855-859 3 76.5 0.13 0.14 0 12.7 0.27 1.49 0.05 0.04 0.01
## # ... with 12 more variables: MgO. <dbl>, dev_6 <dbl>, CaO. <dbl>, dev_7 <dbl>,
## # Na2O. <dbl>, dev_8 <dbl>, K2O. <dbl>, dev_9 <dbl>, P2O5. <dbl>,
## # dev_10 <dbl>, Total. <dbl>, dev_11 <dbl>
gt(unknown_sum)
| id2 | count | SiO2. | dev_1 | TiO2. | dev_2 | Al2O3. | dev_3 | FeOt | dev_4 | MnO. | dev_5 | MgO. | dev_6 | CaO. | dev_7 | Na2O. | dev_8 | K2O. | dev_9 | P2O5. | dev_10 | Total. | dev_11 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 380 | 1 | 76.00 | NA | 0.13 | NA | 12.90 | NA | 1.57 | NA | 0.05 | NA | 0.07 | NA | 0.81 | NA | 4.23 | NA | 4.21 | NA | 0.02 | NA | 100 | NA |
| 387 | 2 | 76.26 | 0.47 | 0.12 | 0.01 | 12.95 | 0.67 | 1.47 | 0.16 | 0.05 | 0.00 | 0.05 | 0.01 | 0.71 | 0.09 | 4.38 | 0.12 | 4.01 | 0.15 | 0.01 | 0.01 | 100 | 0 |
| 410 | 2 | 76.95 | 0.42 | 0.13 | 0.02 | 12.06 | 0.19 | 1.40 | 0.10 | 0.04 | 0.01 | 0.07 | 0.06 | 0.77 | 0.18 | 4.52 | 0.05 | 4.03 | 0.09 | 0.03 | 0.02 | 100 | 0 |
| 420 | 8 | 76.54 | 0.61 | 0.13 | 0.02 | 12.55 | 0.32 | 1.45 | 0.14 | 0.04 | 0.01 | 0.07 | 0.03 | 0.73 | 0.13 | 4.48 | 0.21 | 3.99 | 0.17 | 0.02 | 0.01 | 100 | 0 |
| 442 | 4 | 76.78 | 0.31 | 0.11 | 0.01 | 12.47 | 0.28 | 1.22 | 0.11 | 0.04 | 0.01 | 0.05 | 0.03 | 0.67 | 0.06 | 4.50 | 0.24 | 4.13 | 0.24 | 0.02 | 0.00 | 100 | 0 |
| 454 | 7 | 75.87 | 0.29 | 0.14 | 0.01 | 12.93 | 0.23 | 1.59 | 0.09 | 0.05 | 0.01 | 0.09 | 0.01 | 0.82 | 0.05 | 4.59 | 0.23 | 3.89 | 0.08 | 0.02 | 0.01 | 100 | 0 |
| 475 | 3 | 76.65 | 0.52 | 0.13 | 0.03 | 12.54 | 0.28 | 1.32 | 0.08 | 0.04 | 0.01 | 0.07 | 0.05 | 0.80 | 0.12 | 4.42 | 0.19 | 4.02 | 0.07 | 0.02 | 0.00 | 100 | 0 |
| 480 | 3 | 75.95 | 0.58 | 0.12 | 0.01 | 12.91 | 0.38 | 1.48 | 0.04 | 0.04 | 0.01 | 0.08 | 0.03 | 0.73 | 0.11 | 4.65 | 0.33 | 4.03 | 0.12 | 0.01 | 0.01 | 100 | 0 |
| 505-510 | 16 | 76.77 | 0.50 | 0.11 | 0.02 | 12.50 | 0.31 | 1.31 | 0.25 | 0.04 | 0.01 | 0.05 | 0.04 | 0.67 | 0.11 | 4.37 | 0.25 | 4.16 | 0.19 | 0.01 | 0.00 | 100 | 0 |
| 520-524 | 10 | 76.75 | 0.78 | 0.12 | 0.02 | 12.40 | 0.44 | 1.44 | 0.21 | 0.04 | 0.01 | 0.06 | 0.04 | 0.70 | 0.16 | 4.39 | 0.30 | 4.08 | 0.25 | 0.01 | 0.00 | 100 | 0 |
| 575-579 | 2 | 76.01 | 0.06 | 0.15 | 0.01 | 12.64 | 0.01 | 1.66 | 0.11 | 0.05 | 0.00 | 0.10 | 0.00 | 0.87 | 0.02 | 4.66 | 0.02 | 3.85 | 0.03 | 0.02 | 0.01 | 100 | 0 |
| 605-609 | 7 | 76.42 | 0.23 | 0.13 | 0.03 | 12.73 | 0.23 | 1.46 | 0.19 | 0.04 | 0.01 | 0.10 | 0.01 | 0.87 | 0.04 | 4.25 | 0.26 | 3.99 | 0.28 | 0.02 | 0.01 | 100 | 0 |
| 655-659 | 9 | 76.14 | 0.45 | 0.14 | 0.01 | 12.84 | 0.40 | 1.57 | 0.13 | 0.04 | 0.01 | 0.09 | 0.02 | 0.86 | 0.06 | 4.40 | 0.23 | 3.90 | 0.09 | 0.02 | 0.01 | 100 | 0 |
| 795-799 | 7 | 76.22 | 0.65 | 0.14 | 0.01 | 12.80 | 0.44 | 1.59 | 0.08 | 0.04 | 0.01 | 0.10 | 0.02 | 0.87 | 0.04 | 4.28 | 0.33 | 3.94 | 0.06 | 0.02 | 0.01 | 100 | 0 |
| 855-859 | 3 | 76.48 | 0.13 | 0.14 | 0.00 | 12.74 | 0.27 | 1.49 | 0.05 | 0.04 | 0.01 | 0.10 | 0.00 | 0.90 | 0.02 | 4.24 | 0.12 | 3.85 | 0.05 | 0.02 | 0.01 | 100 | 0 |
chem_red <- filter(chem, age == "WI"|age == "GS2")
c28 <- ggplot(chem_red, aes(x = FeO, y = CaO, fill = id, shape = id))
c28 <- c28 +
geom_hdr(method = "kde", alpha = 0.5, xlim = c(0,100), ylim = c(0,30), show.legend = FALSE, smooth = TRUE, n = 1000, probs = c(0.95)) +
scale_fill_manual(values = chempalette) +
geom_point(data = unknowns, inherit.aes = FALSE, aes(x=FeO, y = CaO, shape = id2, fill = id2), size=4, alpha=0.8) +
xlab("FeO (wt%)") +
ylab("CaO (wt%)") +
scale_fill_manual(values = chempalette) +
scale_shape_manual(values=c(1:5,7,11, 21:25, 21:25, 21:25, 21:25, 21:25, 21:25, 21:25, 21:25, 21:25)) +
Tephra.theme
## Scale for 'fill' is already present. Adding another scale for 'fill', which
## will replace the existing scale.
print(c28)
u28 <- ggplot(chem_red, aes(x = FeO, y = CaO, fill = id, shape = id))
u28 <- u28 + geom_point(aes(fill = id), size=4, alpha=0.8)+xlab("FeO (wt%)")+ylab("CaO (wt%)")+scale_shape_manual(values=c(21:25, 21:25, 21:25, 21:25, 21:25, 21:25, 21:25, 21:25, 21:25, 21:25))+
geom_point(data = unknowns, inherit.aes = FALSE, aes(x=FeO, y = CaO, shape = id2, fill = id2), size=4, alpha=0.8) +
scale_fill_manual(values = chempalette) +
Tephra.theme
ggplotly(u28, width = 1000, height = 800)
R. W. Le Maitre (editor), A. Streckeisen, B. Zanettin, M. J. Le Bas, B. Bonin, P. Bateman, G. Bellieni, A. Dudek, S. Efremova, J. Keller, J. Lamere, P. A. Sabine, R. Schmid, H. Sorensen, and A. R. Woolley, Igneous Rocks: A Classification and Glossary of Terms, Recommendations of the International Union of Geological Sciences, Subcommission of the Systematics of Igneous Rocks. Cambridge University Press, 2002.